﻿@inject ModalService _modalService

<Button OnClick="@ShowConfirm">Confirm</Button>


<Button OnClick="@ShowConfirmNotClose">Confirm</Button>


@code {

    private Func<ModalClosingEventArgs, Task> OnOkClick = async (e) =>
    {
        await Task.Delay(1000);
    };

    private void ShowConfirm()
    {
        RenderFragment icon = @<Icon Type="@IconType.Outline.ExclamationCircle" />;

        _modalService.Confirm(new ConfirmOptions()
        {
            Title = "Do you want to delete these items?",
            Icon = icon,
            Content = "When clicked the OK button, this dialog will be closed after 1 second",
            OnOk = OnOkClick
        });
    }



    private Func<ModalClosingEventArgs, Task> OnNotOkClick = async (e) =>
    {
        await Task.Delay(1000);
        e.Cancel = true;
    };

    private void ShowConfirmNotClose()
    {
        RenderFragment icon = @<Icon Type="@IconType.Outline.ExclamationCircle" />;

        _modalService.Confirm(new ConfirmOptions()
        {
            Title = "Do you want to delete these items?",
            Icon = icon,
            Content = "When clicked the OK button, this dialog will cancel the closing in 1 second",
            OnOk = OnNotOkClick
        });
    }
}
